package com.hopu.pyq.controller;

import com.hopu.pyq.entity.Pyq;
import com.hopu.pyq.service.PyqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
public class PyqController {

    @Autowired
    private PyqService pyqService;

//    @RequestMapping("findAllPyq")
//    public String findAll(Model model){
//        model.addAttribute("pyqs",pyqService.findAllPyq());
//        return "pyq";
//    }

    @GetMapping("/pyqs")
    public ResponseEntity<List<Pyq>> findAll(){
        return ResponseEntity.ok(pyqService.findAllPyq());
    }
}
